package com.sgb.kjwl.view.ui.activity.self.order;

import android.content.Intent;
import android.widget.Toast;

import com.sgb.goods.utils.base.GoodsSdk;
import com.sgb.goods.utils.module.GoodsComponent;
import com.sgb.goods.utils.module.Module;
import com.sgb.kjwl.view.ui.activity.PhotoViewActivity;
import com.sgb.kjwl.view.ui.activity.WebViewX5HostActivity;
import com.sgb.kjwl.view.ui.activity.manage.WebsiteInfoActivity;
import com.sgb.kjwl.view.ui.activity.self.shop.ShopGoodsDetailActivity;
import com.sgb.kjwl.view.ui.activity.self.userInfo.VerificationCodeLoginActivity;
import com.swgk.core.util.ACAdminDialogUtils;

import java.io.Serializable;
import java.util.List;

/**
 * 商品 Module 辅助工具代理组件
 * 注意：请勿删除，该组件是商品 Module 用于 Module 内调用 app 实现的辅助工具
 *
 * @author cyj
 */
@GoodsComponent("包含某些业务场景跳转与其他")
public class GoodsModuleComponent {

    /**
     * 仓储 删除、编辑等操作权限获取
     *
     * @return
     */
    @Module("getStorageOperationPermission")
    public boolean getStorageOperationPermission() {
        int type = ACAdminDialogUtils.isPermission(ACAdminDialogUtils.MK_3_CANGCHUGUANLI, false);
        return type == ACAdminDialogUtils.TYPE_NORMAL;
    }

    /**
     * 品牌管理 删除、编辑等操作权限获取
     *
     * @return
     */
    @Module("getBrandOperationPermission")
    public boolean getBrandOperationPermission() {
        int type = ACAdminDialogUtils.isPermission(ACAdminDialogUtils.MK_3_PINPAIGUANLI, false);
        return type == ACAdminDialogUtils.TYPE_NORMAL;
    }

    /**
     * 询价发布操作权限获取
     *
     * @return
     */
    @Module("getInquiryPublishPermission")
    public int getInquiryPublishPermission() {
        return ACAdminDialogUtils.isPermissionForAsk(ACAdminDialogUtils.MK_OURINQUIRYPRICELIST, true);
    }

    /**
     * 询价发布操作权限获取
     *
     * @return
     */
    @Module("showInquiryPublishDialog")
    public void showInquiryPublishDialog(Integer type) {
        ACAdminDialogUtils.showACDialogForGoods(type, GoodsSdk.getInstance().getTopActivity());
    }

    /**
     * 商品模块跳转至网站
     *
     * @param websiteNo NO
     * @param websiteType 1 企业网站 2 团队网站  3 个人网站
     */
    @Module("jumpWebsiteInfoActivity")
    public void jumpWebsiteInfoActivity(String websiteNo,Integer websiteType) {
        Intent intent = new Intent();
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.putExtra("websiteNo", websiteNo);
        intent.putExtra("websiteType", websiteType);
        intent.setClass(GoodsSdk.getApplication(), WebsiteInfoActivity.class);
        GoodsSdk.getApplication().getApplicationContext().startActivity(intent);
    }

    /***
     * 我的询价-列表-跳转询价详情
     * @param url
     * @param id
     * @param type
     * @param state
     */
    @Module("jumpWebViewX5HostActivity")
    public void jumpWebViewX5HostActivity(String url, String id, String type, String state,String sharTitleText) {
        Intent intent = new Intent();
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.putExtra("url", url);
        intent.putExtra("id", id);
        intent.putExtra("TYPE", type);
        intent.putExtra("STATE", state);
        intent.putExtra("sharTitleText",sharTitleText);
        intent.setClass(GoodsSdk.getApplication(), WebViewX5HostActivity.class);
        GoodsSdk.getApplication().getApplicationContext().startActivity(intent);
    }

    /***
     * 我的报价-报价详情
     * @param url
     */
    @Module("jumpMyOfferDetails")
    public void jumpMyOfferDetails(String url) {
        Intent intent = new Intent();
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.putExtra("url", url);
        intent.setClass(GoodsSdk.getApplication(), WebViewX5HostActivity.class);
        GoodsSdk.getApplication().getApplicationContext().startActivity(intent);
    }

    /***
     * 商品module跳转商品详情
     * @param id    商品id
     * @param skuId    sku id
     */
    @Module("jumpShopGoodsDetailActivity")
    public void jumpShopGoodsDetailActivity(String id, String skuId) {
        Intent intent = new Intent();
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.putExtra("id", id);
        intent.putExtra("from", "");
        intent.putExtra("skuId", skuId);
        intent.setClass(GoodsSdk.getApplication(), ShopGoodsDetailActivity.class);
        GoodsSdk.getApplication().getApplicationContext().startActivity(intent);
    }

    /**
     * 跳转至登录页面
     */
    @Module("jumpVerificationCodeLoginActivity")
    public void jumpVerificationCodeLoginActivity(Integer jumpAddress) {
        Intent intent = new Intent();
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.putExtra("jump_address", jumpAddress);
        intent.setClass(GoodsSdk.getApplication(), VerificationCodeLoginActivity.class);
        GoodsSdk.getApplication().getApplicationContext().startActivity(intent);
    }

    /***
     * 图片预览
     * @param urls         预览的本地地址
     * @param position     点击预览的下标
     */
    @Module("photoPreView")
    public void photoPreView(List<String> urls, Integer position) {
        Intent intent = new Intent();
        intent.setClass(GoodsSdk.getApplication(), PhotoViewActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.putExtra(PhotoViewActivity.KEY_PHOTO_URLS, (Serializable) urls);
        intent.putExtra(PhotoViewActivity.KEY_PHOTO_POSITION, position);
        GoodsSdk.getApplication().getApplicationContext().startActivity(intent);
    }
}
